package com.cloud.xtools.common.config;

import com.cloud.xtools.common.interceptor.RequestAuthorizationInterceptor;
import com.cloud.xtools.common.interceptor.RequestInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Daixinguo
 */
@Configuration
public class RequestInterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new RequestInterceptor())
                // 拦截所有路径
                .addPathPatterns("/**")
                // 排除某些路径
                .excludePathPatterns("/public/**");

        // 登录认证拦截器
        registry.addInterceptor(new RequestAuthorizationInterceptor())
                // 拦截所有路径
                .addPathPatterns("/**")
                // 排除某些路径
                .excludePathPatterns("/public/**");
    }
}
